<?php


/**
 * 留言管理
 * Enter description here ...
 * @author Admin
 *
 */
class MessageAction extends CommonAction{
	
	
	/**
	 * 留言列表
	 * Enter description here ...
	 */
	public function index() {
		$data = Init_GP(array("start","end","name","aid"));  //检索条件
		
		$message = D('Message');
		
		if (!empty($data)){
			if (!empty($data['start']) && !empty($data['end']))	{
				$start_tmp = strtotime($data['start']);
				$end_tmp = strtotime($data['end']);
				$map['addtime']  = array('between',"{$start_tmp},{$end_tmp}");
			}
			if (!empty($data['name']))$map['name']=array('eq',$data['name']);
			if (!empty($data['aid']))$map['aid']=array('eq',$data['aid']);
		}
		
		
		import("@.ORG.Page"); //导入分页类
		$count = $message->where($map)->count();    //计算总数
		
		$p = new Page ($count,10);
		$messagedata=$message->where($map)->limit($p->firstRow.','.$p->listRows)->order('id desc')->findAll();
		
		//分页条件写入
		foreach($data as $key=>$val) {
			$p->parameter   .=   "$key=".$val."&";
		}
		
		$page = $p->show ();
		
		$this->assign("page",$page);
		$this->assign("messagedata",$messagedata);
		
		$this->display();
	}
	
	
	
	/**
	 * 留言回复
	 * @see CommonAction::update()
	 */
	public function update(){
		$data = Init_GP(array('reply','state'));
		
		$id = GetNum($_POST['id']);  //主键ID
		$map['id']=array('eq',$id);
		
		parent::update($data,$map);
	}
	
	
	
	public function add(){
		$this->error('操作错误');
	}
	
	public function dels(){
		$this->error('操作错误');
	}
	
	public function insert(){
		$this->error('操作错误');
	}
	
	
}
?>